#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long int64;
typedef unsigned long long qword;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef vector<pii> vpii;

typedef pair<int64,int64> pii64;
typedef vector<int64> vi64;
typedef vector<vi64> vii64;
typedef vector<vii64> viii64;
typedef vector<pii64> vpii64;

typedef vector<string> vs;

const int dx[]={0,-1,0,1,-1,1, 1,-1};
const int dy[]={1,0,-1,0, 1,1,-1,-1};
const double eps=1e-8;

#define fori(i,a,b) for(int i(a),_b(b);i<=_b;++i)
#define ford(i,a,b) for(int i(a),_b(b);i>=_b;--i)
#define forn(i,n) fori(i,0,n-1)
#define fora(i,a) fori(i,0,a.size()-1)
#define fore(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define maximum(a) (*max_element(all(a)))
#define minimum(a) (*min_element(all(a)))
#define findx(a,x) (find(all(a),x)-a.begin())
#define two(X) (1LL<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define sqr(a) (a)*(a)
#define nmax 1010
#define mmax 200100
#define kmax 11
#define modulo 1000000007
#define maxc 999999999

int point[100][100];
bool win(char a, char b)
{
	return ((a=='R' && b == 'S') || (a=='S' && b == 'P') || (a=='P' && b == 'R'));
}

int calcp(string a, string b)
{
	if (win(a[1], b[1]))
	{
		if (win(a[0], b[0]))
			return 2;
		if (a[0]==b[0])
			return 1;
	}
	return 0;
}

bool freeA[100], freeE[100];
	
class DoubleRoshambo {
public:
	int maxScore(vector <string> A, vector <string> E) {
		int n = A.size();
		int m = E.size();
		forn(i,n) forn(j,m)
		{
			 point[i][j]=calcp(A[i], E[j]);
			freeA[i] = freeE[j]= true;
		}
		int ans = 0;
		for(int k = 2; k >=1; k--)
		{
		 	forn(i,n) forn(j,m)
		 		if (freeA[i] && freeE[j])
		 			if (point[i][j] == k)
		 			{
		 				ans+=k;

		 				freeA[i] = freeE[j]=false;
					}
		}
		return ans;

	}
};


// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit-pf 2.3.0
#include <iostream>
#include <string>
#include <vector>
#include <ctime>
#include <cmath>
using namespace std;
bool KawigiEdit_RunTest(int testNum, vector <string> p0, vector <string> p1, bool hasAnswer, int p2) {
	cout << "Test " << testNum << ": [" << "{";
	for (int i = 0; int(p0.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << "\"" << p0[i] << "\"";
	}
	cout << "}" << "," << "{";
	for (int i = 0; int(p1.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << "\"" << p1[i] << "\"";
	}
	cout << "}";
	cout << "]" << endl;
	DoubleRoshambo *obj;
	int answer;
	obj = new DoubleRoshambo();
	clock_t startTime = clock();
	answer = obj->maxScore(p0, p1);
	clock_t endTime = clock();
	delete obj;
	bool res;
	res = true;
	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
	if (hasAnswer) {
		cout << "Desired answer:" << endl;
		cout << "\t" << p2 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == p2;
	}
	if (!res) {
		cout << "DOESN'T MATCH!!!!" << endl;
	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
		cout << "FAIL the timeout" << endl;
		res = false;
	} else if (hasAnswer) {
		cout << "Match :-)" << endl;
	} else {
		cout << "OK, but is it right?" << endl;
	}
	cout << "" << endl;
	return res;
}
int main() {
	bool all_right;
	bool disabled;
	bool tests_disabled;
	all_right = true;
	tests_disabled = false;
	
	vector <string> p0;
	vector <string> p1;
	int p2;
	
	{
	// ----- test 0 -----
	disabled = false;
	string t0[] = {"RR"};
			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
	string t1[] = {"SS"};
			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
	p2 = 2;
	all_right = (disabled || KawigiEdit_RunTest(0, p0, p1, true, p2) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	{
	// ----- test 1 -----
	disabled = false;
	string t0[] = {"SR","PP"};
			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
	string t1[] = {"PR","RS"};
			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
	p2 = 1;
	all_right = (disabled || KawigiEdit_RunTest(1, p0, p1, true, p2) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	{
	// ----- test 2 -----
	disabled = false;
	string t0[] = {"PP","PP","PP","PP"};
			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
	string t1[] = {"RR","PR","SS","SP"};
			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
	p2 = 3;
	all_right = (disabled || KawigiEdit_RunTest(2, p0, p1, true, p2) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	{
	// ----- test 3 -----
	disabled = false;
	string t0[] = {"PS","RS","PP","SP","RR","SS","SP"};
			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
	string t1[] = {"RP","SP","RR","SR","RS","SP","SS"};
			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
	p2 = 10;
	all_right = (disabled || KawigiEdit_RunTest(3, p0, p1, true, p2) ) && all_right;
	tests_disabled = tests_disabled || disabled;
	// ------------------
	}
	
	if (all_right) {
		if (tests_disabled) {
			cout << "You're a stud (but some test cases were disabled)!" << endl;
		} else {
			cout << "You're a stud (at least on given cases)!" << endl;
		}
	} else {
		cout << "Some of the test cases had errors." << endl;
	}
	return 0;
}
// PROBLEM STATEMENT
// Ash and Elsh invented a new variant of the game Rock-Paper-Scissors called DoubleRoshambo. In the normal game, each of the two players change their right hand into one of these gestures: rock, paper, or scissors. Rock beats scissors; scissors beat paper; paper beats rock. For example, if Ash plays rock and Elsh plays paper, then Elsh wins.
// 
// In DoubleRoshambo, each player uses both hands. Each hand may play different gestures. A player scores:
// 
// 2 points, if his right hand beats his opponent's right hand, and his left hand beats his opponent's left hand.
// 1 point, if his right hand beats his opponent's right hand, and his left hand plays the same gesture as his opponent's left hand.
// 0 points, in all other cases.
// 
// 
// Ash and Elsh played DoubleRoshambo several rounds. You are given two vector <string>s A and E, representing the gestures that Ash and Elsh played, respectively. Each element of A and E will contain two characters. The first character is for their left hand and the second character is for their right hand. For each hand, the character will be one of 'R', 'P', or 'S', representing rock, paper, or scissors, respectively.
// 
// However, the gestures are given in no specific order. Return the maximum points Ash could have possibly scored.
// 
// DEFINITION
// Class:DoubleRoshambo
// Method:maxScore
// Parameters:vector <string>, vector <string>
// Returns:int
// Method signature:int maxScore(vector <string> A, vector <string> E)
// 
// 
// CONSTRAINTS
// -A and E will both contain the same number of elements, between 1 and 50, inclusive.
// -Each element of both A and E will contain exactly 2 characters.
// -Each character in both A and E will be one of 'R', 'P', or 'S'.
// 
// 
// EXAMPLES
// 
// 0)
// {"RR"}
// {"SS"}
// 
// Returns: 2
// 
// They played one round. Ash played RR while Elsh played SS, so Ash scored 2 points.
// 
// 1)
// {"SR", "PP"}
// {"PR", "RS"}
// 
// Returns: 1
// 
// They might have played like this:
// 
// Ash played SR and Elsh played RS, so Ash scored 0 points.
// Ash played PP and Elsh played PR, so Ash scored 1 point.
// 
// 
// In total, Ash scored 1 point.
// 
// 2)
// {"PP", "PP", "PP", "PP"}
// {"RR", "PR", "SS", "SP"}
// 
// Returns: 3
// 
// 
// 
// 3)
// {"PS", "RS", "PP", "SP", "RR", "SS", "SP"}
// {"RP", "SP", "RR", "SR", "RS", "SP", "SS"}
// 
// Returns: 10
// 
// 
// 
// END KAWIGIEDIT TESTING
//Powered by KawigiEdit-pf 2.3.0!
